<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>主页面</title>
</head>
<body>
<form action="dept/list" method="get">
    <p>
        部门名称：<input type="text" name="deptName"/>
        部门状态：
        <select name="status">
            <option selected>所有</option>
            <option value="0">正常</option>
            <option value="1">停用</option>
        </select>
        <input type="submit" value="搜索">&nbsp;&nbsp;&nbsp;
        <input type="reset" value="重置">
    </p>
</form>

<table border="1">
    <tr>
        <td>部门名称</td>
        <td>排序</td>
        <td>状态</td>
        <td>创建时间</td>
        <td>操作</td>

    </tr>

    <c:forEach items="${list}" var="dept">
        <tr>
            <td>${dept.deptName}</td>
            <td>${dept.orderNum}</td>
            <td>${dept.status}</td>
            <td><fmt:formatDate value='${dept.createTime}' pattern='yyyy-MM-dd'/></td>
            <td>
                <a href="byId?id=${returnPerson.id}">编辑</a>
                <a href="byId?id=${returnPerson.id}">新增</a>
                <a href="JavaScript:void(0)" onclick="del(${returnPerson.id})">删除</a>

            </td>
        </tr>
    </c:forEach>
</table>

<p>
    <a href="list?pageNo=1">首页</a>
    <a href="list?pageNo=${pageNo-1}">上一页</a>
    <a href="list?pageNo=${pageNo+1}">下一页</a>
    <a href="list?pageNo=${totalPages}">末页</a>
    &nbsp;&nbsp;
    共${totalCount}条记录
</p>

<script>
    function add() {
        location.href = 'add';
    }

    function del(id) {
        let con = confirm('确认要删除' + id + '吗？')

        if (con) {
            location.href = 'delete?id=' + id;
        }
    }
</script>
</body>
</html>
